package com.cwx.dao;

import com.cwx.pojo.Tag;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TagsRepository extends JpaRepository<Tag,Long> {

    //根据名字查找Tag
    Tag findByName(String name);

    //根据标签所对应的博客数量 查出前相应数量的标签
    @Query("select t from Tag t")
    List<Tag> findTop(Pageable pageable);

}
